<?php
/**
 * Initializes the database by creating the tables:
 * dbBarangay, dbProvince, dbState, dbStore
 * @version April 14, 2011
 * @author Aaron Jarzombek and Brice Rader
 */
?>

<html>
    <title>
        Database Initialization
    </title>
    <body>
        <?php
        echo ("Attempting to install tables...<br />");
        include_once('dbInfo.php');
        include_once('functions.php');
        include_once('dbImage.php');

        $db_server = mysql_connect($host, $username, $password);
        if (!$db_server

            )die("Cannot connect to the MySQL database!<br />Please contact your database administrator.");


        //Connect
        $connected = connectToDatabase();
        if (!$connected) {
            echo ("Connection to the database failed <br />");
            return false;
        }

        mysql_query("DROP DATABASE hapinoy");
        mysql_query("CREATE DATABASE hapinoy");

        mysql_select_db($database) or die("Cannot select the database!<br />
            Please make sure it has been installed properly!");

        //IMAGE
        $result = dbImage::createTable();
        if (!$result

            )die("Could not create table 'province': " . mysql_error());
        echo ("Added table 'images' successfully...<br />");
        ?>
    </body>
</html>